class UIPlayerController extends SimplePC
        dependson(SeqAct_UICollectCoin)
        dependson(SeqAct_UIGivePoints);

var() int UIPoints;

function PlayerTick(float DeltaTime)
{
	Super(GamePlayerController).PlayerTick(DeltaTime);
}

function CollectCoin(SeqAct_UICollectCoin MyAction)
{
  //TODO: Add some effect when collecting coins
  //`log("CollectCoin(): Collected coin");
  //self.TMTCoinsCollected += 1;
  //TestWinningConditions();
}

function AddPoints(SeqAct_UIGivePoints a)
{
  `log("AddPoints() : Adding points: "$a.NumPoints);
  UIPoints += a.NumPoints;
}

function UIFireSpeed(SeqAct_UIFireSpeed a)
{
	local Vehicle CurrentVehicle;

	CurrentVehicle = Vehicle(Pawn);

	if(CurrentVehicle != None) 
	{
		`log("UIFireSpeed() : Setting fire speed: "$a.FireSpeed);
		UIPlayerShip_Weapon(UIPlayerShip_Content(CurrentVehicle).Seats[0].Gun).SetRateOfFire(a.FireSpeed);
	}
}

function UIDamage(SeqAct_UIDamage a)
{
	local Vehicle CurrentVehicle;

	CurrentVehicle = Vehicle(Pawn);

	if(CurrentVehicle != None) 
	{
		`log("UIDamage() : Setting damage: "$a.Damage);
		UIPlayerShip_Weapon(UIPlayerShip_Content(CurrentVehicle).Seats[0].Gun).SetDamage(a.Damage);
	}
}

function UIGiveLife(SeqAct_UIGiveLife a)
{
	Pawn.Health += 100;
}

state PlayerDriving
{
ignores SeePlayer, HearNoise, Bump;

	function ProcessMove(float DeltaTime, vector NewAccel, eDoubleClickDir DoubleClickMove, rotator DeltaRot);

	function ProcessDrive(float InForward, float InStrafe, float InUp, bool InJump)
	{
		local Vehicle CurrentVehicle;

		CurrentVehicle = Vehicle(Pawn);

		if (CurrentVehicle != None)
		{
			bPressedJump = InJump;
			CurrentVehicle.SetInputs(InForward, -InStrafe, InUp);
			CheckJumpOrDuck();			
		}
	}

	function PlayerMove(float DeltaTime)
	{
		local float Forward, Strafe;

		UpdateRotation(DeltaTime);

		// Get the forward input information
		Forward = PlayerInput.aForward;
		// Get the strafe input information
		Strafe = PlayerInput.aStrafe;

		// Clamp the forward to within -1.f and 1.f
		Forward = FClamp(Forward, -1.f, 1.f);
		// Clamp the strafe to within -1.f and 1.f
		Strafe = FClamp(Strafe, -1.f, 1.f);

		ProcessDrive(Forward, Strafe, PlayerInput.aUp, bPressedJump);

		if (Role < ROLE_Authority)
		{
			ServerDrive(PlayerInput.aForward, PlayerInput.aStrafe, PlayerInput.aUp, bPressedJump, ((Rotation.Yaw & 65535) << 16) + (Rotation.Pitch & 65535));
		}

		bPressedJump = false;
	}

	event BeginState(Name PreviousStateName)
	{
		CleanOutSavedMoves();
	}

	event EndState(Name NextStateName)
	{
		CleanOutSavedMoves();
	}
}

defaultproperties
{
	UIPoints = 0
}